home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 7 / FM Towns Free Software Collection 7.iso / t_os / gpen32k / source.exe / LIB / OSRC / TIFFLOAD.C < prev    next >
C/C++ Source or Header  |  1993-08-02  |  1KB  |  54 lines

  1. /************************************************************
  2. *   共通一般ライブラリー                OKOME System 2      *
  3. ************************************************************/
  4.  
  5. #include    <stdio.h>
  6. #include    <string.h>
  7. #include    <math.h>
  8. #include    <EGB.H>
  9. #include    <tifflib.h>
  10. #include    <normlib.h>
  11.  
  12. static xx, xx4, yy;
  13. static FILE *fp;
  14.  
  15. int tlog(char *buf, int lof, int ls)
  16. {
  17.     egbput(xx,yy+lof,xx+xx4-1,yy+lof+ls-1,buf);
  18.     return (0);
  19. }
  20.  
  21. int tfgs(char *buf, long sz)
  22. {
  23.     fread(buf, 1, sz, fp);
  24.     return (0);
  25. }
  26.  
  27. int tiffload(char *name, int xf, int yf)
  28. {
  29.     int x, y, comp, fill, cm;
  30.     long strip, clut;
  31.     char h[4096], ak[2048], tt[DECOMP_WORK_SIZE];
  32.     xx = xf;
  33.     yy = yf;
  34.     if ((fp=fopen(name,"rb"))==NULL)
  35.         return (-1);
  36.     fread(h,1,4096,fp);
  37.     if (TIFF_getHead(h,4096)==-1)
  38.     {
  39.         fclose(fp);
  40.         return (-1);
  41.     }
  42.     cm = TIFF_checkMode( &x, &y, &comp, &fill, &strip, &clut);
  43.     xx4 = x;
  44.     if (cm != 16)
  45.     {
  46.         fclose(fp);
  47.         return (cm);
  48.     }
  49.     TIFF_setLoadFunc(tlog,tfgs);
  50.     TIFF_loadImage( cm, x, y, strip, fill, comp, ak, x, 1024/x, tt );
  51.     fclose(fp);
  52.     return (0);
  53. }
  54.